package org.ticketing.model;

//import java.util.Date;

import java.sql.Date;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.Length;

//import org.hibernate.validator.constraints.*;

@Entity
@Table(name = "users")
public class User {

	// Check constraints/annotations
	/*
	 * I constraints NotNull e Pattern funzionano. 
	 * Funziona anche lo username settato come primary key nel database.
	 * 
	 * */
	
	
	@Id
	@NotNull
	@Size(min = 1, max = 25)
	private String username;
	
	@NotNull
	@Length(min = 8, max = 25) //il controllo non viene effettuato qui
	private String pwd;
	
	@NotNull
	@Size(min = 1, max = 25)
	private String name;
	
	@NotNull
	@Size(min = 1, max = 25)
	private String surname;
	
	@NotNull
	private Date birthdate;
	
	@NotNull
	@Pattern(regexp = "M|F", message = "Invalid pattern")
	private char gender;
	
	
	@NotNull
	@Email
	private String mailAddress;
	
	public User() {}
	
	
	//Ho tenuto anche questo costruttore per non dare errori nella parte di controlol ma sarebbe da togliere
	public User(String username, String pwd){
		this.username = username;
		this.pwd = pwd;
	}
	
	public User(String username, String pwd, String name, String surname, Date birthdate, char gender, String mailaddress) {
		this.username = username;
		this.pwd = pwd;
		this.name = name;
		this.surname = surname;
		this.birthdate = birthdate;
		this.gender = gender;
		this.mailAddress = mailaddress;
	}
	
	public String getUsername() {
		return username;
	}
	
	public void setUsername(String username) {
		this.username = username;
	}

	public String getPwd() {
		return pwd;
	}

	public void setPwd(String pwd) {
		this.pwd = pwd;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSurname() {
		return surname;
	}

	public void setSurname(String surname) {
		this.surname = surname;
	}

	public Date getBirthdate() {
		return birthdate;
	}

	public void setBirthdate(Date birthdate) {
		this.birthdate = birthdate;
	}

	public char getGender() {
		return gender;
	}

	public void setGender(char gender) {
		this.gender = gender;
	}

	public String getMailAddress() {
		return mailAddress;
	}

	public void setMailAddress(String mailAddress) {
		this.mailAddress = mailAddress;
	}
	
}